/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rlpw.util;

import java.util.ArrayList;
import java.util.Collection;

/**
 *
 * @author weinpau
 */
public class UniqueList<T> extends ArrayList<T> {

    @Override
    public boolean add(T e) {
        if (!contains(e)) {
            return super.add(e);
        } else {
            return false;
        }
    }

    @Override
    public boolean addAll(Collection<? extends T> c) {

        boolean in = false;
        for (T obj : c) {
            in |= add(obj);
        }

        return in;
    }

    @Override
    public boolean addAll(int index, Collection<? extends T> c) {

        int ind = index;
        for (T obj : c) {
            if (!contains(obj)) {
                super.add(ind++, obj);
            }

        }
        return true;

    }

    @Override
    public void add(int index, T element) {
        if (!contains(element)) {
            super.add(index, element);
        }


    }
}
